<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:dnic="http://dnic.egov.ws.adaptative.esb.uy.edu.fing.org/">

	<xsl:strip-space elements="*" />
		
	<xsl:output method="xml" media-type="application/xhtml+xml" omit-xml-declaration="yes" encoding="utf-8" indent="yes" />
	
	<xsl:template match="/">				
		<xsl:apply-templates select="soapenv:Envelope" />
	</xsl:template>

	<!-- Process Envelope Object -->
	<xsl:template match="soapenv:Envelope">	
		<xsl:copy>
			<xsl:apply-templates select="soapenv:Header" />		
			<xsl:apply-templates select="soapenv:Body" />	
		</xsl:copy>
	</xsl:template>
	
	<!-- Process Header Object -->
	<xsl:template match="soapenv:Header">
	 	<xsl:copy> 
	 		 <xsl:apply-templates select="@*|node()"/>
	 	</xsl:copy>
	</xsl:template>
	
	<!-- Process Body Object -->
	<xsl:template match="soapenv:Body">
		<xsl:copy>
			<xsl:call-template name="funtionName" />
	 	</xsl:copy>
	</xsl:template>
	
	<!-- Process Function Object -->
	<xsl:template name="funtionName">
		<xsl:apply-templates select="@*|node()"/>
	</xsl:template>
	
	<!-- ###################################### AUXILIARY FUNCTIONS ###################################### -->
	
	<!-- Copy Object Recursive -->
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	
	<!-- ###################################### PROCESS CHANGE IN WSDL ###################################### -->
	
	<!-- obtenerPersona y obtenerPersonaResponse PersonaCanonico obtenerPersona(String CI)  -->
	
	<xsl:template match="dnic:obtenerInformacionPersona">
		<xsl:element name="obtenerPersona">
			<xsl:apply-templates select="@*|node()"/>
		</xsl:element>
	</xsl:template>	
	<xsl:template match="dnic:obtenerInformacionPersona/arg0">
		<xsl:variable name="value" select="../arg0"/>
		<xsl:variable name="valueDig" select="../arg1"/>
		<xsl:element name="arg0">
			<xsl:value-of select="concat(concat(concat(concat(concat(concat(substring($value,1,1),'.'),substring($value,2,3)),'.'),substring($value,5,3)),'-'),$valueDig)"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="dnic:obtenerInformacionPersona/arg1"/>
	
	<xsl:template match="dnic:obtenerInformacionPersonaResponse">
		<xsl:element name="obtenerPersonaResponse">
			<xsl:apply-templates select="@*|node()"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="dnic:obtenerInformacionPersonaResponse/return">
		<xsl:element name="return">
			<xsl:apply-templates select="@*|node()"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="dnic:obtenerInformacionPersonaResponse/return/CIVerificador"/>
	
</xsl:stylesheet>